﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace helloworld2.MODEL
{
    class Vertex
    {
        public int id { get; set; }
        public double distance { get; set; }
        public bool visited { get; set; }
        public bool current { get; set; }
        List<KeyValuePair<int, int>> field = new List<KeyValuePair<int, int>>();
        List<Edge> connections = new List<Edge>();
        public Vertex pD { get; set; } //preDecessor
        VertexContainer vc = VertexContainer.Instance;

        public Vertex(List<KeyValuePair<int, int>> field, int id)
        {
            this.distance = double.PositiveInfinity;
            this.field = field;
            this.id = id;
            this.visited = false;
            this.current = false;
            vc.addVertex(this);
        }

        public Vertex()
        {
        }

        public KeyValuePair<int, int> getCenter()
        {

            if (this.field.Count > 1)
            {
                return this.field[1];
            }

            else
            {
                return this.field[0];
            }
        }

        public List<Edge> getConnection()
        {
            return this.connections;
        }

        public bool lookForCoordinates(KeyValuePair<int, int> coordinates)
        {
            bool re = false;
            if (field.Contains(coordinates))
            {
                re = true;
            }
            return re;
        }

        public void addConnection(Edge e)
        {
            connections.Add(e);
        }

        public void initializeVertex()
        {
            this.distance = double.PositiveInfinity;
            this.visited = false;
            this.pD = null;
        }

        public List<KeyValuePair<int, int>> getField()
        {
            return this.field;
        }

    }
}
